package utils

import (
	"strconv"
	"strings"
	"fmt"
)

func FormatNum(bit int, num float64) (str string) {
	str = strconv.FormatFloat(num, 'f', bit, 64)
	if len(str) < 4 {
		return str
	}
	arr := strings.Split(str, ".")
	length := len(arr[0])

	if length < 4 {
		return str
	}
	count := (length - 1) / 3
	for i := 0; i < count; i++ {
		arr[0] = arr[0][:length-(i+1)*3] + "," + arr[0][length-(i+1)*3:]
	}

	return strings.Join(arr, ".")
}

func main() {
	ret := FormatNum(2, 1223232424)
	fmt.Println(ret)
}
